@extends('Admin.layout.layout')

@section('content')
             <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">广告列表</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>   
             <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
              <div class="row">
              <form action="{{ url('/admin/goods/list') }}" method="get">
                <div class="col-sm-6">
                  <div class="dataTables_length" id="dataTables-example_length">
                    <label>显示
                              <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
                                    <option value="10" @if(!empty($request['num']) && $request['num'] == 10) { selected } @endif>10</option>
                                    <option value="25" @if(!empty($request['num']) && $request['num'] == 25) { selected } @endif>25</option>
                                    <option value="50"  @if(!empty($request['num']) && $request['num'] == 50) { selected } @endif>50</option>
                                    <option value="100"  @if(!empty($request['num']) && $request['num'] == 100) { selected } @endif>100</option>
                              </select> 条
                     </label>
                  </div>
                </div>
                <div class="col-sm-6">
                  <div id="dataTables-example_filter" class="dataTables_filter">
                    <label>广告商:
                       <input name="keywords" value="@if(!empty($request['keywords'])){{$request['keywords']}}@endif" type="search" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" />
                    </label>
                    <button class="btn btn-info" type="submit">查询</button>
                 </div>
                </div>

               <form> 
              </div>
    <div class="row">
     <div class="col-sm-12">
        <table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
            <thead>
                <tr>
                    <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width:10%">ID</th>
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending"  style="width:10%" >广告商</th>
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width:20%;">广告挂起时间</th>   
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width:10%">广告结束时间  </th>
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" >广告费用</th>
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width:20%;">广告内容</th>
                    <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width:15%">编辑</th>
                </tr>
            </thead>
                        <tbody>
                        @foreach($res as $k => $v)

                          <tr class="gradeA odd" role="row" style="height:15px;">
                                <td class="sid">{{ $v->id }}</td>
                                <td>{{ $v->aname }}</td>
                                <td><div  style="overflow:hidden;height:20px;width:150px;">{{$v->atime}}</div></td>
                                <td><div  style="overflow:hidden;height:20px;width:150px;">{{ $v->aetime }}</td>
                                <td>{{ $v->aprice }}</td>
                                <td><div  style="overflow:hidden;height:20px;width:200px;">{{ $v->atext }}</div></td>
                                <td class="cente sorting_1"> <a class="fa fa-trash-o  delete" >删除</a> | <a href="{{url('admin/adver/edit',['id'=>$v->id])}}"class="fa fa-wrench">修改</a></td>
                            </tr>
                        @endforeach   
                        </tbody>
                    </table>
                </div>
            </div>
                        <div class="row">
                          <div class="col-sm-">
                            <!-- 页码 -->

                            <div class="row">
                              <div class="col-sm-12">
                                <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">

                                </div>
                              </div>
                            </div>
                          </div>

                        </div>

                        </div>
@endsection

@section('myjs')
    <script type="text/javascript"> 
      $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
    });
    $('.delete').click(function(){
        // return confirm('你确认删除该商品么？');
        // alert(1111);
        var id = $(this).parents('tr').find('.sid').html();
        var dd = $(this);
        // console.log(id);
        $.post('/admin/adver/delete',{id:id},function(data){
         if(data == 1){
                dd.parents('tr').remove();
            }else{
                alert('删除成功');
            }
        })
        return false;
    });
    </script>
@endsection